package com.example.evistix.piano;

import android.media.MediaPlayer;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    Button doi;
    Button do_up;
    Button re;
    Button re_up;
    Button mi;
    Button fa;
    Button fa_up;
    Button so;
    Button so_up;
    Button la;
    Button la_up;
    Button si;
    Button do2;
    //
    Button maj1;
    Button m2;
    Button m3;
    Button maj4;
    Button maj5;
    Button m6;
    //
    Button dom17;
    Button m27;
    Button m37;
    Button maj47;
    Button dom57;
    Button m67;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        doi = (Button) findViewById(R.id.doi);
        do_up = (Button) findViewById(R.id.do_up);
        re =(Button) findViewById(R.id.re);
        re_up = (Button) findViewById(R.id.re_up);
        mi =(Button) findViewById(R.id.mi);
        fa =(Button) findViewById(R.id.fa);
        fa_up = (Button) findViewById(R.id.fa_up);
        so =(Button) findViewById(R.id.so);
        so_up = (Button) findViewById(R.id.so_up);
        la =(Button) findViewById(R.id.la);
        la_up = (Button) findViewById(R.id.la_up);
        si =(Button) findViewById(R.id.si);
        do2 =(Button) findViewById(R.id.do2);
//
        maj1 =(Button) findViewById(R.id.maj1);
        m2 =(Button) findViewById(R.id.m2);
        m3 =(Button) findViewById(R.id.m3);
        maj4 =(Button) findViewById(R.id.maj4);
        maj5 =(Button) findViewById(R.id.maj5);
        m6 =(Button) findViewById(R.id.m6);
//
        dom17 =(Button) findViewById(R.id.dom17);
        m27 =(Button) findViewById(R.id.m27);
        m37 =(Button) findViewById(R.id.m37);
        maj47 =(Button) findViewById(R.id.maj47);
        dom57 =(Button) findViewById(R.id.dom57);
        m67 =(Button) findViewById(R.id.m67);

        maj1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.doi);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        doi.start();
                        mi.start();
                        so.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                    }
                }) .start();

            }
        });

        dom17.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.doi);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        MediaPlayer qi= new MediaPlayer().create(MainActivity.this,R.raw.la_up);
                        doi.start();
                        mi.start();
                        so.start();
                        qi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                        qi.release();
                    }
                }) .start();

            }
        });
        m2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.re);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.fa);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        doi.start();
                        mi.start();
                        so.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                    }
                }) .start();

            }
        });
        m27.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.re);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.fa);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        MediaPlayer qi= new MediaPlayer().create(MainActivity.this,R.raw.do2);
                        doi.start();
                        mi.start();
                        so.start();
                        qi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                        qi.release();
                    }
                }) .start();

            }
        });

        m3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.si);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        doi.start();
                        mi.start();
                        so.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                    }
                }) .start();

            }
        });

        m37.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.re);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        MediaPlayer qi= new MediaPlayer().create(MainActivity.this,R.raw.si);
                        doi.start();
                        mi.start();
                        so.start();
                        qi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                        qi.release();
                    }
                }) .start();

            }
        });

        maj4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.doi);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.fa);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        doi.start();
                        mi.start();
                        so.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                    }
                }) .start();

            }
        });

        maj47.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.do2);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.fa);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        MediaPlayer qi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        doi.start();
                        mi.start();
                        so.start();
                        qi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                        qi.release();
                    }
                }) .start();

            }
        });

        maj5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.si);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.re);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        doi.start();
                        mi.start();
                        so.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                    }
                }) .start();

            }
        });

        dom57.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.fa);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.re);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        MediaPlayer qi= new MediaPlayer().create(MainActivity.this,R.raw.si);
                        doi.start();
                        mi.start();
                        so.start();
                        qi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                        qi.release();
                    }
                }) .start();

            }
        });
        m6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.doi);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        doi.start();
                        mi.start();
                        so.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                    }
                }) .start();

            }
        });

        m67.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.do2);
                        MediaPlayer mi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        MediaPlayer so= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        MediaPlayer qi= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        doi.start();
                        mi.start();
                        so.start();
                        qi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                        mi.release();
                        so.release();
                        qi.release();
                    }
                }) .start();

            }
        });
        doi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.doi);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });



        do_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.do_up);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });

        re.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

               new Thread(new Runnable() {
                   @Override
                   public void run() {
                       MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.re);
                       doi.start();
                       SystemClock.sleep(3000);
                       doi.release();
                   }
               }) .start();
            }
        });

        re_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.re_up);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });

        mi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.mi);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        fa.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.fa);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        fa_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.fa_up);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        so.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.soi);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        so_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.so_up);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        la.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.la);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        la_up.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.la_up);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });
        si.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.si);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });

        do2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        MediaPlayer doi= new MediaPlayer().create(MainActivity.this,R.raw.do2);
                        doi.start();
                        SystemClock.sleep(3000);
                        doi.release();
                    }
                }) .start();

            }
        });

    }


}
